<?php session_start();
	include('../controller/functions.php');
	User::connection();


	$userArr	= array('admin','student','teacher');
	if(!in_array($_SESSION['user'],$userArr)) {
	User::validSession();

}
if ($_GET['q'] == 'logout') 
{
	User::user_logout();
	print '		
			<script type="text/javascript">		
			window.location = "../login_r.php";
			</script>
			';

}
$email = $_SESSION['em'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="../images/fav.ico">
<link rel="icon" type="image/gif" href="../images/fav.ico">
<title>Profile of <? User::titleUser(); ?> </title>

	<link rel="stylesheet" href="../css/style2.css" type="text/css" charset="utf-8" />
    <link rel="stylesheet" href="../css/front.css" type="text/css" charset="utf-8" />
    	<link type="text/css" href="../css/demo.css" rel="stylesheet" />
        <link type="text/css" href="../css/design.css" rel="stylesheet" />
         <link rel="stylesheet" href="../css/general.css" type="text/css" charset="utf-8" />
</head>
<body>

 <div id="page">
<div id="wrapper">
        		 
        		   <div class="header_top" id="header_top"> </div>
  </div>
  <div class="header2"></div> 
	<div class="header"><!--open logo -->
		  </div><!--end header -->
	<!-- close logo-->
<!-- hide the client inquiries php-->
    <?php

	
    echo '<div id="nav">';
    echo '<div class="underlinemenu">';
	include('menu_view.php');
	echo '</div>';
    echo '</div>';
	?>
    <div id="header_in"> <!--open header -->
     <p> </p>
    <table width="100%" height="56">
     <tr>
       <td width="317" align="left" class="date"> 
        <? User::oras(); ?>
        </td>
            
       <td width="388" align="right"><? User::showPic(); ?></td>
       <td width="279">&nbsp;&nbsp;<? User::showUser(); ?>        </td>
       </tr>
   </table>
    </div>
    <div id="ex">
    </div>
      <p> </p>
       <div id="body"> <!--open body -->
    
	 <div id="sidebar"> 
       <!-- <div id="chef_ind"> open chef -->
        <div id="welcome"> <!--open welcome -->
         <!-- <h2 class="guilded"></h2> -->
        </div> <!--close welcome-->

<? echo '<p class="more">';
echo '';
 
   require('sideBar.php');
    
echo'</p>';
?>

        </div>
        
     <!--</div>close left -->
      
    

    
       <?php
	$sel = $_GET['sel']; 

	if($sel != 'profile')
	{	switch($sel):

	case 'changedp': 	echo "<div id='content'>
	<div class='desriptionHeader'><!--open dec -->
	<div class='container'><!--open booking -->
          					<div class='post3'><h1>Change Profile Picture</h1></div>
            				<div class='desriptionHeader'> <!--open right-->
       						<div class='postbg2'><!--open booking -->";
						include('changedp.php');
						break;	
						
	case 'dpupload':	echo "<div id='content'>
	<div class='desriptionHeader'><!--open dec -->
	<div class='container'><!--open booking -->
          					<div class='post3'><h1>Upload Result:</h1></div>
            				<div class='desriptionHeader'> <!--open right-->
       						<div class='postbg2'><!--open booking -->";
						include('dpupload.php');
						break;
	endswitch;
	}
	else
	{
	echo " <div id='content'>
	<div class='desriptionHeader'><!--open dec -->
	<div class='container'><!--open booking -->
          <div class='post3'><h1>My Profile</h1></div>
            <div class='desriptionHeader'> <!--open right-->
       <div class='postbg'><!--open booking -->";
	  
	   
	$data = mysql_query("SELECT * from `tbluser` where email='$email'"); //where condition
	echo "$row[userid]";
	
	while($row = mysql_fetch_array($data)){	
	if($row[15] == NULL)//if dp is null... set to default pic
	{$up_query = mysql_query("UPDATE `tbluser` SET avatar='defaultdp.png' WHERE email='$email'");}
	
	$y = mysql_query("SELECT * FROM `tblsection` WHERE studentNumber = '$row[userid]'");
		while($r = mysql_fetch_array($y)){
			$sec = "$r[sectionName]";
			$yr = "$r[yearLevel]";
		}
	
	echo "<br/>
	Your Last Login was $row[14] 

		<br/><br/>
		
		
<table width='75%' border='0' cellspacing='0' cellpadding='0' >
  <tr>
 	<td rowspan='7' width='10%'><div class='img_h' style='margin-left:10px'>
		<img src='avatar/"."$row[15]"."' width='150px' />
		<a href='profile.php?sel=changedp'>
		<span class='desc'>
		Change Picture
		</span>
		</a>
		</div>&nbsp;
	</td>
	<td rowspan='7' width='5%'>&nbsp;</td>
    <td class='left_, theads' width='40%'>Name</td>
    <td width='55%'>: $row[1] $row[2] $row[3]</td>
  </tr>
  <tr>
    <td class='left_, theads'>Year & Section</td>
    <td>: $yr / $sec</td>
  </tr>
  <tr>
    <td class='left_, theads'>Address</td>
    <td>: $row[7], $row[6]</td>
  </tr>
  <tr>
    <td class='left_, theads'>E-mail Add.</td>
    <td>: $row[10]</td>
  </tr>
  <tr>
    <td class='left_, theads'>Contact Details</td>
    <td>: $row[8]/$row[9]</td>
  </tr>
  <tr>
    <td class='left_, theads'>Birthday</td>
    <td>: $row[5]</td>
  </tr>
  <tr>
    <td class='left_, theads'>USERNAME</td>
    <td>: $row[username]</td>
  </tr>

  ";  
  }
}
  ?>
</table> 
      
	 
   </div><!--close desc -->
   
          
     				
	  </div><!--close booking -->
   </div><!--close desc -->
    	</div>
	 
<!--close desc -->
    	</div> <!--close right-->
      <div class="clear">&nbsp;</div>
 <!-- footer-->
 <?php 
	  echo '<div id="footer">';
     include('footer_view.php');
      echo '</div>';	
	  ?>

    </div><!-- close body-->
</div><!-- close page-->


</body>
</html>
